"""
画出一个二次函数，同时画出梯形法求积分时的各个梯形
"""
import matplotlib.pyplot as plt
import numpy as np


def func(x):
    return x ** 2 + 3 * x + 4


x = np.linspace(-5, 5, 50)
y = func(x)
a = np.linspace(-5, 5, num=15)
for i in range(15):
    plt.plot([a[i], a[i]], [0, func(a[i])], color='black')
plt.ylim(ymin=0)
plt.plot(x, y, color='green')
plt.show()
